home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-24 | 3.8 KB | 133 lines | [TEXT/Help] |
- {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
- {••• Help start file for rel 1.4 •••}
- {•••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••}
-
- {••• The backquote. The following code should not be removed or modified ! •••}
-
- (define (system:quasiquote s)
- (cond (null? s) ()
- (atom? s) (list 'quote s)
- (eq? (0 s) 'unquote) (1 s)
- (cons? (0 s)) (cond (eq? (0 (0 s)) 'unquote-splicing)
- (if (null? (-1 s)) (1 (0 s))
- (list 'append (1 (0 s)) (system:quasiquote (-1 s))))
- † (list 'cons (system:quasiquote (0 s))
- (system:quasiquote (-1 s))))
- † (list 'cons (system:quasiquote (0 s))
- (system:quasiquote (-1 s)))))
-
- (defmacro (quasiquote s) (system:quasiquote s))
- (defmacro (unquote | s) 'unquote)
- (defmacro (unquote-splicing | s) 'unquote-splicing)
-
- {••• Reading a CODE ressource inside Help to include external code •••}
-
- (defmacro (defext fic seg nom xref str | arg)
- `(begin (define (,nom ,@arg))
- (coerce ,nom 13)
- (force (car=! ,nom (getext ,xref ,seg ,fic)))
- (coerce ,nom 12)
- (setstrict ,nom ,str) ',nom))
-
- {••• The kappa syntaxic form is as lambda, but defines STRICT procedures •••}
-
- (defmacro (kappa | l)
- `(setstrict (lambda ,@l) %1111111111111111))
-
- {••• The defkap syntaxic form is as define but defines STRICT procedures •••}
-
- (defmacro (defkap f | b)
- (cond (cons? f) `(define ,(0 f)
- (setstrict (lambda ,(-1 f) ,@b) %1111111111111111))
- `(define ,f ,@b)))
-
- {••• Some procedures that should be assembly code translated… •••}
-
- (define (append l1 l2)
- (cond (null? l1) l2
- (cons (0 l1) (append (-1 l1) l2))))
-
- (define (reverse l | bag)
- (cond (null? l) bag
- (apply reverse (cons (-1 l)(cons (0 l) bag)))))
-
- (defkap (memq? o l)
- (cond (null? l) ƒ
- (eq? o (0 l)) l
- (memq? o (-1 l))))
-
- (defkap (mem=? o l)
- (cond (null? l) ƒ
- (=? o (0 l)) l
- (mem=? o (-1 l))))
-
- (defkap (equal? l1 l2)
- (cond (=? l1 l2) †
- (cons? l1)(and (cons? l2)(equal? (0 l1)(0 l2))(equal? (-1 l1)(-1 l2)))))
-
- (defkap (member? o l)
- (cond (null? l) ƒ
- (equal? o (0 l)) l
- (member? o (-1 l))))
-
- (defkap (nequal? l1 l2)
- (not (equal? l1 l2)))
-
- {••• Procedures on ORDERED number STREAMS •••}
-
- (defkap (union l1 l2)
- (cond (<? (0 l1)(0 l2))(cons (0 l1) (union (-1 l1) l2))
- (=? (0 l1)(0 l2))(cons (0 l1)(union (-1 l1)(-1 l2)))
- (cons (0 l2) (union l1 (-1 l2)))))
-
- (defkap (inter l1 l2)
- (cond (<? (0 l1)(0 l2)) (inter (-1 l1) l2)
- (=? (0 l1)(0 l2))(cons (0 l1)(inter (-1 l1)(-1 l2)))
- (inter l1 (-1 l2))))
-
- (defkap (diff l1 l2)
- (cond (=? (0 l1)(0 l2)) (diff (-1 l1) l2)
- (<? (0 l1)(0 l2)) (cons (0 l1) (diff (-1 l1) l2))
- (diff l1 (-1 l2))))
-
- {••• Some good old combinators •••}
-
- (define (I x) x)
-
- (define Y
- ((lambda(a)
- (lambda(b) (b ((a a) b)))) (lambda(a)
- (lambda(b) (b ((a a) b))))))
-
- {••• The map closure, should also be assembly coded •••}
-
- (define (map f | l)
- (amap f l))
-
- (defkap (amap f l)
- (cond (atom? f)(apply f l)
- (cons (amap (0 f) (allcar l))
- (amap (-1 f) (allcdr l)))))
-
- (defkap (allcar l)
- (cond (null? l) ()
- (cons (0 (0 l)) (allcar (-1 l)))))
-
- (defkap (allcdr l)
- (cond (null? l) ()
- (cons (-1(0 l)) (allcdr (-1 l)))))
-
- {••• Some closures for streams •••}
-
- (define (consif kar kdr)
- (cond kar (cons kar kdr)
- kdr))
-
- (define (reduce f b l)
- (cond (null? l) b
- (f (0 l) (reduce f b (-1 l)))))
-
- (define (suchas p f)
- (cond (p (0 f)) (cons (0 f) (suchas p (-1 f)))
- (suchas p (-1 f))))
-